package com.ychen.other;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

/**
 * @Author chenyuliao
 * @Date 2019/7/21 12:48
 */
public class Test02 {
    public static void main(String[] args) {
        String userString = "{\"age\":12,\"name\":\"张三\"}";
        String userTypeString = "{\"@type\":\"com.ychen.other.User\",\"age\":12,\"name\":\"张三\"}";
        String userTypeString2 = "{\"@type\":\"com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl\",\"age\":12,\"name\":\"张三\"}";
        Object u3 = JSON.parseObject(userString, Object.class);
        Object u4 = JSON.parseObject(userTypeString, Object.class);
        Object u5 = JSON.parseObject(userTypeString2, Object.class);
        Object u6 = JSON.parseObject(userTypeString2, User.class);
        System.out.println(u3);
        System.out.println(u4);
        System.out.println(u5);
        System.out.println(u6);
    }


//    public static void main(String[] args) throws Exception {
//
//        Object runtime=Class.forName("java.lang.Runtime")
//                .getMethod("getRuntime",new Class[]{})
//                .invoke(null);
//
//        Class.forName("java.lang.Runtime")
//                .getMethod("exec", String.class)
//                .invoke(runtime,"calc.exe");
//    }
}
